package cms.manage.template.value.impl;

import cms.bean.DataView;
import cms.bean.PageView;
import cms.bean.help.Help;
import cms.bean.help.HelpType;
import cms.bean.template.Forum;
import cms.manage.template.impl.HelpTemplateManage;
import cms.manage.template.value.TplValueStrategy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

import static cms.common.SystemConstant.DisplayType.*;

@Service("在线帮助")
public class HelpStratey implements TplValueStrategy {
    @Resource
    HelpTemplateManage helpTemplateManage;//在线帮助 -- 模板方法实现

    @Override
    public Object doOperation(Forum forum, Map submitParameter, Map runtimeParameter) {
        if(forum.getForumChildType().equals("在线帮助列表")){
            if(forum.getDisplayType().equals(DISPLAY_MONOLAYER.getValue())){//单层
                DataView<Help> value = helpTemplateManage.helpMonolayer(forum, submitParameter,runtimeParameter);
                return value;
            }else if(forum.getDisplayType().equals(DISPLAY_PAGE.getValue())){//分页
                PageView<Help> value = helpTemplateManage.helpPage(forum, submitParameter,runtimeParameter);
                return value;
            }else if(forum.getDisplayType().equals(DISPLAY_COLLECTION.getValue())){//集合
                List<Help> value = helpTemplateManage.help_collection(forum, submitParameter,runtimeParameter);
                return value;
            }
        }else if(forum.getForumChildType().equals("推荐在线帮助")){
            if(forum.getDisplayType().equals(DISPLAY_COLLECTION.getValue())){//集合
                List<Help> value = helpTemplateManage.recommendCollection(forum, submitParameter,runtimeParameter);
                return value;
            }
        }else if(forum.getForumChildType().equals("在线帮助分类")){
            if(forum.getDisplayType().equals(DISPLAY_COLLECTION.getValue())){//集合
                List<HelpType> value = helpTemplateManage.typeCollection(forum, submitParameter,runtimeParameter);
                return value;
            }
        }else if(forum.getForumChildType().equals("在线帮助导航")){
            if(forum.getDisplayType().equals(DISPLAY_COLLECTION.getValue())){//集合
                Map<Long,String> value = helpTemplateManage.navigationCollection(forum, submitParameter,runtimeParameter);
                return value;
            }
        }else if(forum.getForumChildType().equals("在线帮助内容")){
            if(forum.getDisplayType().equals(DISPLAY_ENTITYBEAN.getValue())){//实体对象
                Help value = helpTemplateManage.contentEntityBean(forum, submitParameter,runtimeParameter);
                return value;
            }
        }
        return null;
    }
}
